package com.yang.controller.wx;

import com.yang.bean.MarketUser;
import com.yang.bean.common.BaseRespVo;
import com.yang.bean.common.CommonData;
import com.yang.bean.fxy.bo.CollectAddordeleteBo;
import com.yang.service.wx.WXCollectService;
import com.yang.utils.UserUtil;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName WXCollectController
 * @Description:
 * @Author TrueEnd
 * @Date 2022/9/11
 * @Version
 **/
@RestController
@RequestMapping("wx/collect")
public class WXCollectController {
    @Autowired
    WXCollectService wxCollectService;

    @Autowired
    DefaultWebSessionManager defaultWebSessionManager;

    @RequestMapping("list")
    @ResponseBody
    public BaseRespVo collectList(Integer type,Integer page,Integer limit){



        CommonData data = wxCollectService.collectList(type,page,limit);


        return BaseRespVo.ok(data);
    }


    @RequestMapping("addordelete")
    public BaseRespVo collectAddordelete(@RequestBody CollectAddordeleteBo collectAddordeleteBo, HttpServletRequest request) {

        MarketUser userMsg = UserUtil.getUserMsg(request, defaultWebSessionManager);

        wxCollectService.collectAddordelete(collectAddordeleteBo.getType(),collectAddordeleteBo.getValueId(),userMsg.getId());

        return BaseRespVo.ok();
    }



}
